// Package coding_round_1 15-82
// @Title coding_round_1
// @Description
// @Author  == 琳琳也叫王木木 ==  2021/9/9 11:48
// @Create  2021/9/9 11:48
package coding_round_1

// 删除链表中重复的元素
func DeleteDuplicates(head *ListNode) *ListNode {
	if head == nil {
		return nil
	}

	dummy := &ListNode{0, head}

	cur := dummy
	for cur.Next != nil && cur.Next.Next != nil {
		if cur.Next.Val == cur.Next.Next.Val {
			x := cur.Next.Val
			for cur.Next != nil && cur.Next.Val == x {
				cur.Next = cur.Next.Next
			}
		} else {
			cur = cur.Next
		}
	}
	return dummy.Next
}
